/**
 * 存储cookie数据
 * @param {string} key 键
 * @param {string || object} val 数据
 * @param {string} s 时间/秒
 */
function setcookie(key, val, s = 10) {
    if (typeof val === 'object') val = JSON.stringify(val)
    const d = new Date
    d.setTime(d.getTime() - 1000 * 60 * 60 * 8 + 1000 * s)
    document.cookie = `${key}=${val}; expires=${d}` + s
}

/**
 * 删除cookie数据
 * @param {string} key 键
 */
function removecookie(key) {
    setcookie(key, null, -1)
}

/**
 * 获取cookie数据
 * @param {string} key 键
 * @returns 
 */
function getcookie(key) {
    let arr = document.cookie.split('; ')
    for (let i = 0; i < arr.length; i++) {
        let temp = arr[i].split('=')
        if (temp[0] === key) return temp[1]
    }
}